//
//  CategoryView.m
//  beautyAccompany
//
//  Created by xiaocankeji on 15/11/25.
//  Copyright © 2015年 xiaocankeji. All rights reserved.
//

#import "CategoryView.h"

#define  kIconHeight  60
#define  kContentHeight 15

@interface CategoryView ()
@property (nonatomic, strong) UIImageView *icon;
@property (nonatomic, strong) UILabel *contentLabel;

@end

@implementation CategoryView



-(instancetype)initCategoryView;
{
    self = [CategoryView buttonWithType:UIButtonTypeCustom];
    
    if (self) {
        
        [self setBackgroundImage:[UIImage imageWithColor:[UIColor whiteColor]] forState:UIControlStateNormal];
        [self setBackgroundImage:[UIImage imageWithColor:RGBA(222, 222, 222, 1)] forState:UIControlStateHighlighted];
        
        
        _icon = [[UIImageView alloc] init];
        [self addSubview:_icon];
        
        _contentLabel = [[UILabel alloc] init];
        _contentLabel.font = kFont(14);
        _contentLabel.textAlignment = NSTextAlignmentCenter;
        _contentLabel.textColor = RGBA(88, 88, 88, 1);
        [self addSubview:_contentLabel];
    }
    return self;
}

- (void)layoutSubviews
{
    _icon.frame = CGRectMake((self.width - kIconHeight)/2, (self.height - kIconHeight - kContentHeight)/2, kIconHeight, kIconHeight);
    _contentLabel.frame = CGRectMake(0, _icon.origin.y+kIconHeight+10, self.width, kContentHeight);
    
}
- (void)setCategory:(MPCategory *)category
{
    if (category) {
        [_icon sd_setImageWithURL:[NSURL URLWithString:category.icon.url] placeholderImage:[UIImage imageNamed:@"abc"]];
        _contentLabel.text = category.title;
        _category = category;
    }
    
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
